package Pet.Management.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import Pet.Management.domain.entity.PetFinder;

@Repository
public interface PetFinderRepository extends JpaRepository<PetFinder, Long> {
    
    /**
     * 查询用户的AI寻宠记录
     */
    @Query("SELECT pf FROM PetFinder pf WHERE pf.user.id = :userId ORDER BY pf.createTime DESC")
    Page<PetFinder> findByUserId(@Param("userId") Long userId, Pageable pageable);
    
    /**
     * 根据状态查询寻宠记录
     */
    @Query("SELECT pf FROM PetFinder pf WHERE pf.status = :status ORDER BY pf.createTime DESC")
    Page<PetFinder> findByStatus(@Param("status") Integer status, Pageable pageable);
} 